package com.newtouch.bxzs.database.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;
import com.newtouch.bxzs.database.config.MyLog;
import com.newtouch.bxzs.database.model.bo.MemberInfoBO;
import com.newtouch.bxzs.database.model.vo.MemberInfoVO;
import com.newtouch.bxzs.database.service.MemberInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;

/**
 * 机构成员信息
 *
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>22020/2/22 10:41</td>
 * <td>wangzhen</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author wangzhen
 * @version 1.0.0
 * @since 1.0.0
 */
@Api(tags = "机构成员信息")
@RestController
@RequestMapping(value = "/memberInfoController")
@SuppressWarnings("unchecked")
public class MemberInfoController {

    /**
     * 静态变量：系统日志
     */
    private static final Log logger = LogFactory.getLog(MemberInfoController.class);

    @Autowired
    private MemberInfoService memberInfoService;

    @PostMapping(value = "/getMemberInfoList")
    @ApiOperation(value = "机构成员列表查询")
    @MyLog(systemFunctionName = "机构成员列表", systemFunctionUrl = "/memberInfoController/getMemberInfoList", userOperationType = 4, userOperationSummary = "机构成员列表查询")
    public BaseResponse<IPage<MemberInfoBO>> getMemberInfoList(@RequestBody MemberInfoVO memberInfoVO) {
        logger.info("成员列表查询");
        IPage<MemberInfoBO> memberList = memberInfoService.getMemberList(memberInfoVO);
        if (ObjectUtils.isEmpty(memberList)) {
            RespGenerator.returnError("未查询到符合条件的机构成员信息");
        }
        return RespGenerator.returnOK(memberList);
    }

    @PostMapping(value = "/getMemberInfoDetail")
    @ApiOperation(value = "机构成员详情查询")
    @MyLog(systemFunctionName = "机构成员列表", systemFunctionUrl = "/memberInfoController /getMemberInfoDetail", userOperationType = 4, userOperationSummary = "机构成员详情查询")
    public BaseResponse<MemberInfoBO> getMemberInfoDetail(@RequestBody HashMap<String, String> map) {
        logger.info("成员列表查询");
        MemberInfoBO member = memberInfoService.getMemberInfo(map.get("userId"));
        return RespGenerator.returnOK(member);
    }
}
